Every time base contains a rate, a start time, a stop time, a current time, and some status information. The Movie Toolbox provides a number of functions that allow your application to work with the contents of a time base. This section describes those functions.
The GetTimeBaseTime function lets you retrieve the current time value of a time base. You can set the current time value by calling the SetTimeBaseTime function--this function requires you to provide a time structure. Alternatively, you can set the current time based on a time value by calling the SetTimeBaseValue function.
You can determine the rate of a time base by calling the GetTimeBaseRate function. You can set the rate of a time base by calling the SetTimeBaseRate function. You can determine the effective rate of a specified time base (relative to the master time base to which it is subordinate) by calling the GetTimeBaseEffectiveRate function.
You can retrieve the start time of a time base by calling the GetTimeBaseStartTime function. You can set the start time of a time base by calling the SetTimeBaseStartTime function. Similarly, you can use the GetTimeBaseStopTime and SetTimeBaseStopTime functions to work with the stop time of a time base.
The Movie Toolbox provides functions that allow you to work with the status information of a time base. The GetTimeBaseStatus function allows you to read the current status of a time base. The GetTimeBaseFlags function helps you obtain the control flags of a time base. You can set these flags by calling the SetTimeBaseFlags function.
The SetTimeBaseTime function allows your application to set the current time of a time base. You must specify the new time in a time structure.
pascal void SetTimeBaseTime (TimeBase tb, const TimeRecord *tr);
If you set the current time of a time base that is the master time base for other time bases, the current times in all the dependent time bases are changed appropriately. If you change the current time in a time base that relies on a master time base, the Movie Toolbox changes the offset between the time base and the master time base--the master time base is not affected.
The SetTimeBaseValue function allows your application to set the current time of a time base. You must specify the new time as a time value.
pascal void SetTimeBaseValue (TimeBase tb, TimeValue t,
TimeScale s);
If you set the current time of a time base that is the master time base for other time bases, the current times in all the dependent time bases are changed appropriately. If you change the current time in a time base that relies on a master time base, the Movie Toolbox changes the offset between the time base and the master time base--the master time base is not affected.
Your application can use the GetTimeBaseTime function to obtain the current time value from a time base. You can specify the time scale in which to return the time value.
pascal TimeValue GetTimeBaseTime (TimeBase tb, TimeScale s,
TimeRecord *tr);
The GetTimeBaseTime function returns a time value that contains the current time from the specified time base in the specified time scale. The function returns this value even if you specify a time structure with the tr parameter.
You can set the current time of a time base by calling either the SetTimeBaseTime or SetTimeBaseValue functions, which are described on SetTimeBaseTime and SetTimeBaseValue , respectively.
The SetTimeBaseRate function allows your application to set the rate of a time base.
pascal void SetTimeBaseRate (TimeBase tb, Fixed r);
You can determine the number of time units that pass each second for a time base by multiplying its rate by the time scale of its time coordinate system. For example, if you set the rate of a time base to 2 and the time base has a time scale of 2, that time base passes through 4 units of its time each second.
Rates may be set to negative values. Negative rates cause time to move backward for the time base.
The GetTimeBaseRate function allows your application to retrieve the rate of a time base.
Rates may be set to negative values. Negative rates cause time to move backward for the time base.
pascal Fixed GetTimeBaseRate (TimeBase tb);
The GetTimeBaseEffectiveRate function returns the effective rate at which the specified time base is moving, relative to its master clock.
pascal Fixed GetTimeBaseEffectiveRate (TimeBase tb);
The GetTimeBaseEffectiveRate function is useful when you need to make scheduling decisions based on the rate of a time base--for example, when you are writing a media handler. (For more on media handlers, see Inside Macintosh: QuickTime Components.) By calling GetTimeBaseEffectiveRate rather than the GetTimeBaseRate function (described in the previous section), you can easily take into account any time base subordination that may be in effect.
You can set the start time of a time base by calling the SetTimeBaseStartTime function. The start time defines the time base's minimum time value. You must specify the new start time in a time structure.
pascal void SetTimeBaseStartTime (TimeBase tb,
const TimeRecord *tr);
Do not use this function to restrict the Movie Toolbox to a portion of a movie--use the SetMovieActiveSegment function (described on SetMovieActiveSegment ) instead.
You can determine the start time of a time base by calling the GetTimeBaseStartTime function.
pascal TimeValue GetTimeBaseStartTime (TimeBase tb, TimeScale s,
TimeRecord *tr);
You can set the stop time of a time base by calling the SetTimeBaseStopTime function. The stop time defines the time base's maximum time value. You must specify the new stop time in a time structure.
pascal void SetTimeBaseStopTime (TimeBase tb,
const TimeRecord *tr);
Do not use the SetTimeBaseStopTime function to restrict the Movie Toolbox to a portion of a movie--use the SetMovieActiveSegment function (described on SetMovieActiveSegment ) instead.
You can determine the stop time of a time base by calling the GetTimeBaseStopTime function.
pascal TimeValue GetTimeBaseStopTime (TimeBase tb, TimeScale s,
TimeRecord *tr);
The SetTimeBaseFlags function allows your application to set the contents of the control flags of a time base.
pascal void SetTimeBaseFlags (TimeBase tb, long timeBaseFlags);
The GetTimeBaseFlags function allows your application to obtain the contents of the control flags of a time base.
pascal long GetTimeBaseFlags (TimeBase tb);
The GetTimeBaseFlags function returns the control flags of a time base. The following flags are defined (unused flags are set to 0):
Your application can retrieve status information from a time base by calling the GetTimeBaseStatus function. This status information allows you to determine when the current time of a time base would fall outside of the range of values specified by the start and stop times of the time base. This can happen when a time base relies on a master time base or when its time has reached the stop time.
pascal long GetTimeBaseStatus (TimeBase tb,
TimeRecord *unpinnedTime);
The GetTimeBaseStatus function returns flags that indicate whether the returned time value is outside the range of values specified by the start and stop times of the time base. The following flags are defined (unused flags are set to 0):